<template>
  <div>
    <HomeHeader :userData="userData" />
    <!-- <router-view></router-view> -->
    <!-- <router-view></router-view> -->
    <HomeMiddle :userPlayList="userPlayList" :myPlayList="myPlayList" :notMyPlayList="notMyPlayList"/>
  </div>
</template>

<script>
import HomeHeader from './HomeHeader.vue'
import HomeMiddle from './HomeMiddle.vue'
import HomeFooter from './HomeFooter.vue'
import { getUserPlayList } from '../../netWork/easeRequest/easePlaylistserver'

export default {
  name: 'Homepage',
  components: {
    HomeHeader,
    HomeMiddle,
    HomeFooter,
  },

  data() {
    return {
      // 用户信息
      userData: '',
      // 用户歌单信息
      userPlayList: '',
      // 我创建的歌单
      myPlayList: [],
      // 推荐的歌单
      notMyPlayList: [],
    };
  },

  created() {
    let that = this
    that.userData = JSON.parse(localStorage.getItem('userData'))

    let uid = 504431777 // 暂时写死
    // let uid = userData.account.id
    // 获取用户歌单
    getUserPlayList(uid)
    .then(res => {
      console.log(res)
      if (res.data.code == 200) {
        that.userPlayList = res.data.playlist
        res.data.playlist.map(item => {
          if(item.creator.userId == uid) {
            that.myPlayList.push(item)
          }else{
            that.notMyPlayList.push(item)
          }
        })
        console.log('我创建的歌单==>>', that.myPlayList)
        console.log('我收藏的歌单==>>', that.notMyPlayList)
      }
      else {
        that.$message({
          type: 'warning',
          message: '获取用户歌单信息异常'
        })
      }
    })
  },

  methods: {
    
  },
};
</script>

<style lang="less" scoped>

</style>